
package org.chart4jsf;

import java.io.IOException;

import javax.faces.component.FacesComponent;
import javax.faces.component.UIComponentBase;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;

@FacesComponent(value = "HtmlHelloWorld")
public class HtmlHelloWorld extends UIComponentBase {

    @Override
    public String getFamily() {

	return null;
    }

    @Override
    public void encodeAll(FacesContext context) throws IOException {

	ResponseWriter writer = context.getResponseWriter();
	writer.startElement("div", this);
	writer.writeAttribute("id", this.getClientId(context), null);
	writer.writeAttribute("style", "color : red", null);
	String msg = (String) this.getAttributes().get("msg");
	if (msg == null)
	    writer.writeText("HelloWorld! today is: " + new java.util.Date(), null);
	else
	    writer.writeText(msg, null);
	writer.endElement("div");
    }
}